package com.dingwen.treasure.kettle.controller;

import com.dingwen.treasure.kettle.base.controller.BaseViewController;
import com.dingwen.treasure.kettle.base.vo.Result;
import com.dingwen.treasure.kettle.service.CategoryService;
import com.dingwen.treasure.kettle.vo.CategoryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 　CategoryController: 目录
 * 　@author dingwen
 * 　@date 2022/8/21
 */
@Api(tags = "资源库目录API")
@RestController
@Slf4j
@RequestMapping("category")
public class CategoryController implements BaseViewController {

    @Resource
    private CategoryService categoryService;

    @GetMapping("/tree")
    @ApiOperation(value = "查询资源库目录树")
    @Cacheable(cacheNames = "category",key = "#root.methodName")
    public Result<List<CategoryVo>> getCategoryTree() {
        return success(categoryService.getCategoryTree());
    }
}
